package com.sctu.adapter;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.sctu.EMSApp.PlayFoodMoreListActivity;
import com.sctu.EMSApp.R;
import com.sctu.bean.PlayFoodList;
import com.sctu.bean.PlayFoodListOne;
import com.sctu.http.UrlConfig;
import com.sctu.httpvollry.GetVolleyHttp;

import java.util.List;

/**
 * Created by Administrator on 2015/12/13.
 */
public class PlayFoodMoreListviewAdapter extends BaseAdapter {


    private PlayFoodList list;
    private Activity context;
    //头部图片
    private ImageView foodlistoneheadimg;
    //item的title
    private TextView foodlistonetitletext;
    //item的价格
    private TextView foodlistonepricetext;
    //item的地址
    private TextView foodlistoneadresstext;
    //item的联系电话
    private TextView foodlistonephonetext;


    public PlayFoodMoreListviewAdapter(Activity context, PlayFoodList list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        if (list != null) {
            return list.getResults().size();
        } else {
            return 0;
        }

    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View view, ViewGroup viewGroup) {
        View views = LayoutInflater.from(context).inflate(R.layout.item_amuse_more, null);

        //设置item头部图片
        foodlistoneheadimg = (ImageView) views.findViewById(R.id.amuse_list_item_head_img);
        GetVolleyHttp.getInstance(context).setImageLoader(foodlistoneheadimg, R.drawable.error_image, R.drawable.error_image,UrlConfig.URL+ list.getResults().get(position).getPath());
        //设置 item的title
        foodlistonetitletext = (TextView) views.findViewById(R.id.amuse_list_item_title_text);
        foodlistonetitletext.setText(list.getResults().get(position).getTitle());
        //设置item的价格
        foodlistonepricetext = (TextView) views.findViewById(R.id.amuse_list_item_price_text);
        foodlistonepricetext.setText(list.getResults().get(position).getPrice());
        //设置item的地址
        foodlistoneadresstext = (TextView) views.findViewById(R.id.amuse_list_item_adress_text);
        foodlistoneadresstext.setText(list.getResults().get(position).getAddress());
        //设置item的联系电话
        foodlistonephonetext = (TextView) views.findViewById(R.id.amuse_list_item_phone_text);
        foodlistonephonetext.setText(list.getResults().get(position).getPhone());


        return views;
    }
}
